package com.zjitc.controller.testcontroller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import redis.clients.jedis.Jedis;

import java.util.Iterator;
import java.util.Set;

/**
 * Create by IntelliJ IDEA
 *
 * @author: lhl
 * @date-Time: 2018/4/8 0008
 * @description:
 */
@Controller
public class RedisUserControl {

    @Autowired
    private Jedis jedis;

    @RequestMapping(value = "/getAllUserName")
    @ResponseBody
    public String getAllUserName() {
        Set<String> users = jedis.smembers("users");
        System.out.println(users);
        // 获取数据并输出
        Iterator<String> it = users.iterator();
        while (it.hasNext()) {
            String key = it.next();
            System.out.println(key);
        }
        return String.valueOf(users);
    }
}
